package edu.pku.sei.transformation.editor.controller.commands.link;

import edu.pku.sei.transformation.editor.model.execution.INode;
import edu.pku.sei.transformation.editor.model.execution.ObjectFlow;

public class ObjectFlowDeleteCommand extends AbstractLinkDeleteCommand<ObjectFlow, INode, INode>{
	public ObjectFlowDeleteCommand(
			ObjectFlow link,
			INode source, INode target) {
		super(link, source, target);
	}
	
	@Override
	public void execute() {
		link.setSource(null);
		link.setTarget(null);
		source.getOutgoings().remove(link);
		target.getIncomings().remove(link);
	}
	
	@Override
	public void undo() {
		link.setSource(source);
		link.setTarget(target);
		source.getOutgoings().add(link);
		target.getIncomings().add(link);
	}
}
